<template>
	<view class="wrap" style="padding-top:50rpx;">
		<view class="reg-text">欢迎注册</view>
        <u-tabs :list="list" :is-scroll="false" :current="current" @change="onClickItem"></u-tabs>
			<view class="list">
        <view class="list-call" >
				<view class="iconfont icon-shouji" style="font-size: 22px;color:#5473e8;"></view>
          <input class="u-input" type="text" v-model="phoneNo" maxlength="32" placeholder="请输入手机号"  />
        
        </view>
       <view class="list-call">
       	<view class="iconfont icon-key" style="font-size: 22px;color:#5473e8;"></view>
       	<input class="u-input" type="text" v-model="password" maxlength="32" :placeholder="$t('login.placeholderPassword')" :password="!showPassword" />
       	<image class="u-icon-right" :src="'/static/aidex/login/eye_' + (showPassword ? 'open' : 'close') + '.png'" @click="showPass()"></image>
       </view>
			</view>
		<view class="button" @click="getCode()"><text>获取验证码</text></view>
		<view class="bottom-box">
			<view class="copyright">
				注册即代表您已阅读并同意<u-link href="#">用户协议</u-link> 与 <u-link href="#">隐私政策</u-link>
			</view>
		</view>
	</view>
</template>
<script>
export default {

	data() {
		return {
      current: 0,
      showPassword: false,
			phoneNo: '',
      password: '',
      list: [{name: '家长端'}, {name: '教师端'}],
		};
	},
	onLoad() {
	},
	methods: {
    onClickItem(index) {
    					this.current = index;
    			},
    showPass() {
    	this.showPassword = !this.showPassword;
    },
		getCode(){
      const phoneregex = /^1[3-9]\d{9}$/;
      const regex = /^(?=.*?[A-Za-z])(?=.*?[0-9]).{8,}$/;
      if (!phoneregex.test(this.phoneNo)) {
                this.$u.toast('手机号格式错误');
                return null;
            } 
      if (!regex.test(this.password)) {
                this.$u.toast('密码格式错误');
                return null;
            } 
			uni.showLoading({
								title: '正在获取验证码',
								mask: true
							})
			this.$u.api.sendCode({
				phoneNo: this.phoneNo,
         codeType: '1',
			})
			.then(res => {
				if (res.code == '200') {
       
            
            setTimeout(() => {
            	uni.navigateTo({
            		url: '/pages/sys/login/registerCode?phoneNo='+this.phoneNo+'&password='+ this.password+'&current='+this.current,
            
            	});
            }, 500);
            
            
	
				}else{
					this.$u.toast(res.msg);
				}
			});
		}
	}
};
</script>
<style lang="scss">
@import 'index.scss';

.agreement {
	display:flex;
	flex-direction:row;
	align-items:center;
	margin-left:90rpx;
	color:#666;
}
.uni-input-placeholder{
	font-size: 32rpx;
}

.uni-input-input{
	font-size: 32rpx;
}
.bottom-box{
	position: fixed;
	bottom:40rpx;
	text-align: center;
	width: 100%;
}
.copyright{
	text-align: center;
	color: #939393;
	width: 100%;
	font-size: 24rpx;
	.u-link{
		margin: 0 10rpx;
		font-size: 24rpx!important;
	}
}
</style>
